<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

//权限验证
if( Role::init() == false ){
	exit('没有权限');
}

$db = new DB('star');

$title_id = isset($_GET['title_id']) ? intval($_GET['title_id']) : 0;

$this_history_id = isset($_GET['this_history_id']) ? intval($_GET['this_history_id']) : 0;//当前版本
$old_history_id = isset($_GET['old_history_id']) ? intval($_GET['old_history_id']) : 0;//调用哪个老版本

if($old_history_id > 0){//读取了历史版本
	$star_sql = 'select * from star_history where title_id='.$title_id.' and history_id='.$old_history_id.' limit 1';
	$star_rs = $db->query($star_sql)->getOne();
	
	$star_sql_1 = 'select * from star where title_id='.$title_id.' and is_del=1 limit 1';
	$star_rs_1 = $db->query($star_sql_1)->getOne();
	$star_rs['index_top'] = $star_rs_1['index_top'];
	$star_rs['updated'] = $star_rs_1['updated'];
}else{
	$star_sql = 'select * from star where title_id='.$title_id.' and is_del=1 limit 1';
	$star_rs = $db->query($star_sql)->getOne();
}

if($star_rs['updated'] < 1367748681){
	$star_rs['content'] = h_d($star_rs['content']);
}

$track_sql = 'select * from star_track where title_id='.$title_id.' order by track_id desc';
$track_rs = $db->query($track_sql)->getAll();

//包含模板
require template('admin/star/star_edit');